﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BUS;
using DTO;

namespace DentalSoftware
{
    public partial class TimBenhNhan : Form
    {
        private BenhNhanForm bnf;
        private DieuTriForm dtf;
        public TimBenhNhan(Form form, int loai)
        {
            InitializeComponent();
            if (loai == 1)
                bnf = (BenhNhanForm)form;
            else
                dtf = (DieuTriForm)form;
        }

        private void btnThoat_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.No;
            this.Close();
        }

        private void btnTim_Click(object sender, EventArgs e)
        {
            if (bnf != null)
            {
                bnf.kqtimBN.Ma = int.Parse(txtMa.Text);
                bnf.kqtimBN.Hoten = txtHoTen.Text;
                if (rbnNam.Checked)
                    bnf.kqtimBN.Gioitinh = 0;
                else
                    bnf.kqtimBN.Gioitinh = 1;
                bnf.kqtimBN.Ngaysinh = new DateTime(int.Parse(txtNamSinh.Text), int.Parse(txtThangSinh.Text), int.Parse(txtNgaySinh.Text));
            }
            else
            {
                dtf.kqtimBN.Ma = int.Parse(txtMa.Text);
                dtf.kqtimBN.Hoten = txtHoTen.Text;
                if (rbnNam.Checked)
                    dtf.kqtimBN.Gioitinh = 0;
                else
                    dtf.kqtimBN.Gioitinh = 1;
                dtf.kqtimBN.Ngaysinh = new DateTime(int.Parse(txtNamSinh.Text), int.Parse(txtThangSinh.Text), int.Parse(txtNgaySinh.Text));
            }
            this.DialogResult = DialogResult.Yes;
            this.Close();
        }       
    }
}
